package com.gtxc.kotlinmvvm.ui.activity;

import android.os.Bundle;
import android.util.Log;

import androidx.lifecycle.Observer;

import com.aleyn.mvvm.base.BaseActivity;
import com.drake.statusbar.StatusBarKt;
import com.gtxc.kotlinmvvm.BR;
import com.gtxc.kotlinmvvm.R;
import com.gtxc.kotlinmvvm.databinding.ActivityNewsDetailsBinding;
import com.gtxc.kotlinmvvm.network.request.ParticularsBean;
import com.gtxc.kotlinmvvm.viewmodle.NewsDetailsViewModle;

import org.jetbrains.annotations.Nullable;

/**
 * FileName:NewsDetailsActivity
 * Author：Administrator
 * Date:2021 2021/9/29 19:46
 * Copyright (C), 2020-2021,成都拇音科技有限公司
 * <p>
 * <p>
 * Description: 新闻详情
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
//新闻详情
public class NewsDetailsActivity extends BaseActivity<NewsDetailsViewModle, ActivityNewsDetailsBinding> {
    @Override
    public int layoutId() {
        return R.layout.activity_news_details;
    }

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        StatusBarKt.immersive(this, getResources().getColor(R.color.white), true);

        int id = getIntent().getIntExtra("id", 0);
        if (id!=0){
            viewModel.InitData(id);
        }
        viewModel.getParticularsBean().observe(this, new Observer<ParticularsBean>() { //注册观察者,观察数据的变化
            @Override
            public void onChanged(ParticularsBean demoData) {
               getMBinding().tv01.setText("【"+demoData.getTitle()+"】");
                getMBinding().tv02.setText(demoData.getCreateTime());
                getMBinding().tv03.setText(demoData.getContent());
            }
        });

    }

    @Override
    public void initData() {

    }

    @Override
    public void initCLick() {

    }

    @Override
    public int variableID() {
        return BR.NewsDetailsViewModle;
    }

    @Override
    public void bindViewModel() {

    }
}
